package com.cuntian.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cuntian.dto.PageDTO;
import com.cuntian.entity.Friend;
import com.cuntian.result.Result;
import com.cuntian.result.ResultUtils;
import com.cuntian.service.IFriendService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cuntian
 * @since 2025-02-01
 */
@RestController
@RequestMapping("/friend")
@RequiredArgsConstructor
public class FriendController {

    private final IFriendService iFriendService;

    /*发起好友请求*/
    @PostMapping("/addFriend")
    public Result<String> addFriend(Long fid){
        iFriendService.addFriend(fid);
        return ResultUtils.success("发送好友请求成功");
    }

    /*删除好友请求*/
    @DeleteMapping("/delFriend")
    public Result<String> delFriend(Long fid){
        iFriendService.delFriend(fid);
        return ResultUtils.success("删除好友成功");
    }

    /*查询好友请求*/
    @GetMapping("/selFriendRequest")
    public Result<Page<Friend>> selFriendRequest(PageDTO pageDTO){
        return ResultUtils.success(iFriendService.selFriendRequest(pageDTO));
    }

    /*同意好友请求*/
    @GetMapping("/confirmFriendRequest")
    public Result<String> confirmFriendRequest(Long shipId){
        iFriendService.confirmFriendRequest(shipId);
        return ResultUtils.success("接受好友请求");
    }

    /*查询我的好友*/
    @GetMapping("/selMyFriend")
    public Result<Page<Friend>> selMyFriend(PageDTO pageDTO){
        return ResultUtils.success(iFriendService.selMyFriend(pageDTO));
    }



}
